<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/4/23
  Time: 19:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
</head>
<%-- 周依博！！菜品遍历页面测试--%>
<body>
<table id="tab">
    <tr>
        <td>编号：</td>
        <td>名称：</td>
        <td>价格：</td>
        <td>图片：</td>
        <td>类别：</td>
        <td>操作：</td>
    </tr>
</table>
<script>
    $(function () {
        $.ajax({
            url:'ShowFoodServlet',
            type:'POST',
            dataType:'json',
            success:function (data) {
                $.each(data,function (i,n) {
                    var $tr="<tr>"+
                            "<td>"+n.fid+"</td>"+
                        "<td>"+n.name+"</td>"+
                        "<td>"+n.price+"</td>"+
                        "<td>"+"<div style='width: 100px;height: 100px'><img style='width: 100px;height: 100px' src='upfiles/"+n.pic+"'> </div>"+"</td>"+
                        "<td>"+n.type.type+"</td>"+
                        "<td>"+"<a href='DeleteFoodServlet?foodid="+n.fid+"'>删除</a>" +
                        "<a href='GetFoodIdServlet?foodid="+n.fid+"&typeid="+n.type.tid+"'>编辑</a>"+"</td>"+
                            "</tr>";
                    $("#tab").append($tr);
                })

            }
        })
    })
</script>


</body>
</html>
